
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<style>
			body {
				background: black;
				color: rgb(80, 80, 80);
			}
			body, pre, #legend span {
				font-family: Menlo, monospace;
				font-weight: bold;
			}
			#topbar {
				background: black;
				position: fixed;
				top: 0; left: 0; right: 0;
				height: 42px;
				border-bottom: 1px solid rgb(80, 80, 80);
			}
			#content {
				margin-top: 50px;
			}
			#nav, #legend {
				float: left;
				margin-left: 10px;
			}
			#legend {
				margin-top: 12px;
			}
			#nav {
				margin-top: 10px;
			}
			#legend span {
				margin: 0 5px;
			}
			.cov0 { color: rgb(192, 0, 0) }
.cov1 { color: rgb(128, 128, 128) }
.cov2 { color: rgb(116, 140, 131) }
.cov3 { color: rgb(104, 152, 134) }
.cov4 { color: rgb(92, 164, 137) }
.cov5 { color: rgb(80, 176, 140) }
.cov6 { color: rgb(68, 188, 143) }
.cov7 { color: rgb(56, 200, 146) }
.cov8 { color: rgb(44, 212, 149) }
.cov9 { color: rgb(32, 224, 152) }
.cov10 { color: rgb(20, 236, 155) }

		</style>
	</head>
	<body>
		<div id="topbar">
			<div id="nav">
				<select id="files">
				
				<option value="file0">intset\intset.go (95.5%)</option>
				
				</select>
			</div>
			<div id="legend">
				<span>not tracked</span>
			
				<span class="cov0">not covered</span>
				<span class="cov8">covered</span>
			
			</div>
		</div>
		<div id="content">
		
		<pre class="file" id="file0" style="display: none">package intset

import (
        "bytes"
        "fmt"
)

//!+intset

// An IntSet is a set of small non-negative integers.
// Its zero value represents the empty set.
type IntSet struct {
        words []uint64
}

// Has reports whether the set contains the non-negative value x.
func (s *IntSet) Has(x int) bool <span class="cov8" title="1">{
        word, bit := x/64, uint(x%64)
        return word &lt; len(s.words) &amp;&amp; s.words[word]&amp;(1&lt;&lt;bit) != 0
}</span>

// Add adds the non-negative value x to the set.
func (s *IntSet) Add(x int) <span class="cov8" title="1">{
        word, bit := x/64, uint(x%64)
        for word &gt;= len(s.words) </span><span class="cov8" title="1">{
                s.words = append(s.words, 0)
        }</span>
        <span class="cov8" title="1">s.words[word] |= 1 &lt;&lt; bit</span>
}

// UnionWith sets s to the union of s and t.
func (s *IntSet) UnionWith(t *IntSet) <span class="cov8" title="1">{
        for i, tword := range t.words </span><span class="cov8" title="1">{
                if i &lt; len(s.words) </span><span class="cov8" title="1">{
                        s.words[i] |= tword
                }</span><span class="cov0" title="0"> else {
                        s.words = append(s.words, tword)
                }</span>
        }
}

//!-intset

//!+string

// String returns the set as a string of the form "{1 2 3}".
func (s *IntSet) String() string <span class="cov8" title="1">{
        var buf bytes.Buffer
        buf.WriteByte('{')
        for i, word := range s.words </span><span class="cov8" title="1">{
                if word == 0 </span><span class="cov8" title="1">{
                        continue</span>
                }
                <span class="cov8" title="1">for j := 0; j &lt; 64; j++ </span><span class="cov8" title="1">{
                        if word&amp;(1&lt;&lt;uint(j)) != 0 </span><span class="cov8" title="1">{
                                if buf.Len() &gt; len("{") </span><span class="cov8" title="1">{
                                        buf.WriteByte(' ')
                                }</span>
                                <span class="cov8" title="1">fmt.Fprintf(&amp;buf, "%d", 64*i+j)</span>
                        }
                }
        }
        <span class="cov8" title="1">buf.WriteByte('}')
        return buf.String()</span>
}</pre>
		
		</div>
	</body>
	<script>
	(function() {
		var files = document.getElementById('files');
		var visible;
		files.addEventListener('change', onChange, false);
		function select(part) {
			if (visible)
				visible.style.display = 'none';
			visible = document.getElementById(part);
			if (!visible)
				return;
			files.value = part;
			visible.style.display = 'block';
			location.hash = part;
		}
		function onChange() {
			select(files.value);
			window.scrollTo(0, 0);
		}
		if (location.hash != "") {
			select(location.hash.substr(1));
		}
		if (!visible) {
			select("file0");
		}
	})();
	</script>
</html>
